/**
 * 
 */
package com.litty.gftshp.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.HistoryListener;
import com.litty.gftshp.client.ui.LoginPanel;

/**
 * @author Litty
 *
 */
public class Home implements EntryPoint, HistoryListener {

	DataServiceAsync dataService;

	public Home() {
		dataService = DataService.Util.getInstance();
		History.addHistoryListener(this);
	}
	
	public void onModuleLoad() {
		String initToken = History.getToken();
		if (initToken.length() == 0) {
			initToken = UIHelper.HIST_TOKEN_LOGIN;
			History.newItem(initToken);
		} else {
			onHistoryChanged(initToken);
		}
	}

	public void onHistoryChanged(String historyToken) {
		if(historyToken.equalsIgnoreCase(UIHelper.HIST_TOKEN_LOGIN))
			new LoginPanel(dataService);		
	}
}
